<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>colorize</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const colorize = (...args) => ({
            black: `\x1b[30m${args.join(' ')}`,
            red: `\x1b[31m${args.join(' ')}`,
            green: `\x1b[32m${args.join(' ')}`,
            yellow: `\x1b[33m${args.join(' ')}`,
            blue: `\x1b[34m${args.join(' ')}`,
            magenta: `\x1b[35m${args.join(' ')}`,
            cyan: `\x1b[36m${args.join(' ')}`,
            white: `\x1b[37m${args.join(' ')}`,
            bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`,
            bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`,
            bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`,
            bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`,
            bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`,
            bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
            bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
            bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
        });
        console.log(colorize('eveningwater').red);
        console.log(colorize(colorize('夕水').cyan).bgBlue);
    </script>
</body>

</html>